clear all;
year=87:1:96;

load('comm_loc.mat'); comm_loc=comm_loc(:,1:11);
cd ..; cd ..; cd ..;
load('code_main_model\6_implied_w_r\input\comm_loc_model.mat','comm_loc_model');
cd 'code_figure_table\OA\Figure OA19_21';

correct_baseline(1:10)=0;
for i=1:10
    new_data=find(comm_loc(:,1)==0 & comm_loc(:,i+1)==1);
    new_model=find(comm_loc_model(:,1)==0 & comm_loc_model(:,i+1)==1);
    correct_baseline(i)=length(intersect(new_data,new_model))/length(new_data);
end

correct_seq=[0.481481481481481	0.705882352941177	0.705882352941177	0.750000000000000	0.668508287292818	0.681992337164751	0.722772277227723	0.755952380952381	0.785340314136126	0.832946635730859];
overlap=[0.925925925925926	0.970588235294118	0.964705882352941	0.971153846153846	0.966850828729282	0.946360153256705	0.950495049504951	0.955357142857143	0.955497382198953	0.960556844547564];

fig=figure('color', [1 1 1 ], 'Position',[200 200 800 340]);
subplot(1,2,1)
axis square
plot(year, correct_baseline, '-b' , 'LineWidth', 2 );
hold on
plot(year, correct_seq, '--k' , 'LineWidth', 2 );

title( 'A. Correct prediction ratio', 'FontSize',15,'Interpreter','Latex');
xlabel('year', 'FontSize',12,'Interpreter','Latex');
ylabel('correct prediction ratio', 'FontSize',12,'Interpreter','Latex');
legend('baseline','sequential choice','Interpreter','Latex','location','northwest');
xlim([87 96]);
ylim([0.4,1]);
yticks(0.4:0.2:1)
set(gca,'FontSize',12);
%  get(handle,'position')

subplot(1,2,2)
axis square
plot(year, overlap.*100, '-b' , 'LineWidth', 2 );

title( [{'B. Fraction of new branches opened'}, {'in the same markets'}], 'FontSize',15,'Interpreter','Latex');
xlabel('year', 'FontSize',12,'Interpreter','Latex');
ylabel('fraction of new branches (\%)', 'FontSize',12,'Interpreter','Latex');
xlim([87 96]);
ylim([92 100]);
yticks(92:2:100)
set(gca,'FontSize',12);
%  get(handle,'position')